package com.core.web.converters;


import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.beanutils.Converter;


public class DateConversor implements Converter
{
	private final SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy");
	
	@SuppressWarnings("unchecked")
	public Object convert(Class classe, Object valor)
	{
		try
		{
			if (valor != null && ((valor instanceof String) && (classe == Date.class)))
			{
				return f.parse((String) valor);
			}
			return valor;
		}
		catch (Exception e)
		{
			return null;
		}
	}
}